home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr11 / pdox693.zip / TI1109.ASC < prev    next >
Text File  |  1992-08-17  |  6KB  |  199 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Paradox                               NUMBER  :  1109
  9.   VERSION  :  4.0
  10.        OS  :  DOS
  11.      DATE  :  August 17, 1992                          PAGE  :  1/3
  12.  
  13.     TITLE  :  Record Locks on a Network in Paradox 4.0
  14.  
  15.  
  16.  
  17.  
  18.   Intended Audience:
  19.   General network, PAL programmer
  20.  
  21.   Prerequisites:
  22.   Basic understanding of table locks from Chapter 21 of Paradox 4.0
  23.   User's Guide.  Use of multi-table forms from Chapter 16 of
  24.   Paradox 4.0's User's Guide.  Use of CoEdit mode.  A knowledge of
  25.   PAL is helpful.
  26.  
  27.   Purpose:
  28.   Give a basic understanding of record locks to Paradox network
  29.   administrators and PAL programmers.  Overall, this Tech Info
  30.   sheet is aimed more toward programmers.
  31.  
  32.  
  33.   First, a brief review of table locks:
  34.  
  35.        FL  -  Full lock, prevents other users from accessing the
  36.               table.
  37.        WL  -  Write lock, prevents other users from modifying the
  38.               table.
  39.        PWL -  Prevent write lock, guarantees that you can modify
  40.               the table.
  41.        PFL -  Prevent full lock, guarantees that you can view and
  42.               read from the table.
  43.  
  44.   In Paradox 4.0, there are three kinds of record locks: record
  45.   lock, write record lock, and group lock.
  46.  
  47.   1)  Interactively, you get a record lock by modifying an existing
  48.   record or by using <ALT-L>.  In PAL, you usually get this through
  49.   LOCKRECORD (you can also use POSTRECORD [...] LEAVELOCKED, which
  50.   handles key violations better).  You get exclusive modify access
  51.   to the record, equivalent to both a PWL and WL on a table, but
  52.   other users can view and read it.  However, you do not get a
  53.   group lock from the record lock.
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Paradox                               NUMBER  :  1109
  75.   VERSION  :  4.0
  76.        OS  :  DOS
  77.      DATE  :  August 17, 1992                          PAGE  :  2/3
  78.  
  79.     TITLE  :  Record Locks on a Network in Paradox 4.0
  80.  
  81.  
  82.  
  83.  
  84.   2)  You get a write record lock on the master record whenever you
  85.   lock one of the details in a 1-1 or 1-M form.  This is equivalent
  86.   to a WL on a table.  Two users can both have write record locks,
  87.   but you can't get a record lock if someone else has a write
  88.   record lock and vice versa.  From the viewpoint of other users, a
  89.   write record lock is the same as a record lock.
  90.  
  91.   NOTE: In fact, you cannot tell the difference between a record
  92.   lock and a write record lock.  If you do a RECORDSTATUS("Locked")
  93.   on the master with a write record lock, it will come back True,
  94.   but you won't be able to modify any of the fields (not just the
  95.   key(s)).  To check for this condition, use the following code
  96.   (this assumes that you were able to previously lock a detail
  97.   record):
  98.  
  99.      LOCKRECORD
  100.      IF RETVAL = False THEN
  101.         IF ERRORCODE() = 9 THEN       ; check to see if record
  102.                                       ; locked by someone else
  103.            ; You still have the write record lock, and another user
  104.            ; prevented you from getting the record lock
  105.         ELSE
  106.            ; You now have a record lock
  107.         ENDIF
  108.      ELSE
  109.         ; You shouldn't be here, as that would mean you didn't have
  110.         ; a detail locked previously.  You now have a record lock.
  111.      ENDIF
  112.  
  113.   3)  You get a group lock when you modify the key field(s) of a
  114.   master record.  This gives you a pseudo-record lock on all
  115.   details that have a 1-1 or 1-M relationship.  You must have a
  116.   record lock on the master to get a group lock, but having a
  117.   record lock does not necessarily guarantee that you can get a
  118.   group lock.
  119.  
  120.   NOTE: There is no way to achieve a group lock other than by
  121.   attempting to modify the key field(s) of the master.  Therefore,
  122.   you must use the following code to determine whether you can
  123.   obtain a group lock (it assumes you already have a record lock):
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Paradox                               NUMBER  :  1109
  141.   VERSION  :  4.0
  142.        OS  :  DOS
  143.      DATE  :  August 17, 1992                          PAGE  :  3/3
  144.  
  145.     TITLE  :  Record Locks on a Network in Paradox 4.0
  146.  
  147.  
  148.  
  149.  
  150.      MOVETO [Key]
  151.      Key = []                      ; Save the key value
  152.      CTRLBACKSPACE
  153.      IF ERRORCODE() = 65 THEN         ; You get errorcode 65 when
  154.         MESSAGE "Can't lock master"   ; you can't get a group lock
  155.      ELSE
  156.         [] = Key                      ; Restore the key value
  157.      ENDIF
  158.         .
  159.         .  <insert your code here>
  160.         .
  161.  
  162.   To remove any of the three types of locks, hit <ALT-L> in
  163.   interactive Paradox, or use UNLOCKRECORD in PAL.
  164.  
  165.   Here are some common situations.  To test them, set up a pair of
  166.   workstations right next to each other:
  167.  
  168.   -- User1 has Detail in table view with record lock.  User2 has
  169.   Master in formview with record lock.  User2 tries to modify
  170.   Master's key.  Gets an error message "Detail group locked by
  171.   User1".  You can only get the group lock when you have the
  172.   capability to record lock *all* the details.
  173.  
  174.   -- User1 is in Master form, with Detail record lock.  User2 has a
  175.   second Detail record lock in the same form.  Both users now have
  176.   a write RECORD LOCK on the master, and neither will be able to
  177.   modify it.  You get the standard record lock message "Master has
  178.   been locked by UserX".
  179.  
  180.   -- User1 is in multi-table form for Master1, User2 in Master2,
  181.   both forms with Detail in 1-M relationship.  Either user can
  182.   record lock MasterX, either user can record lock any detail
  183.   record.  If a Detail that User1 has locked also belongs to a
  184.   Master2 that User2 tries to modify the key field on, User2 will
  185.   get a group lock error.
  186.  
  187.   DISCLAIMER: You have the right to use this technical information
  188.   subject to the terms of the No-Nonsense License Statement that
  189.   you received with the Borland product to which this information
  190.   pertains.
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.